#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>

using namespace std;

class Solution {
public:
    string addStrings(string num1, string num2) {
        string s = "";
        int t = 0;
        for (int i = num1.size() - 1, j = num2.size() - 1; i >= 0 || j >= 0; i--, j--)
        {
            if (i >= 0) t += num1[i] - '0';
            if (j >= 0) t += num2[j] - '0';
            s += (t % 10 + '0');
            t /= 10;
        }
        if (t) s += (t + '0');
        reverse(s.begin(), s.end());
        return s;
    }
};

int main()
{
    Solution s;
    string a = s.addStrings("123", "22");
    cout << a << endl;

}